<?php
    
    include '../public/db_object.php';
    if(isset($_POST)){
        $data = $_POST['data'];
        $id_name = $_POST['id_name'];
        $id = $_POST['id'];

       
        $data = json_decode($data, true);
       // echo "<pre>";
        //var_dump($data);
 
        $gname = $data['gname'];
        $description = $data['description'];
        $identifier = $data['identifier'];
        $is_best = $data['is_best'];
        $recycle = $data['recycle'];
        $status = $data['status'];
        $new_data = [
          'cid'=> $data['cid'],
          'price' => $data['price'],
          'stock' => $data['stock'],
          'gname'=> "'$gname'",
          'description'=> "'$description'",
          'identifier'=> "'$identifier'",
          'is_best'=> "'$is_best'",
          'recycle'=> "'$recycle'",
          'status'=> "'$status'"
        ];
        
        // echo "<pre>";
        // var_dump($new_data);
        // exit;

        $db = new DB_object(['db_name'=> 'db_shop']);
        $ret = $db->l_update_one('t_goods', $new_data, $id_name.'='.$id);

        if($ret){
            echo 1;
        }
        else{
          echo 0;
        }

    }

?>